package org.other.testPk;

/**
 * @Author yu
 * @Date 2022/7/8
 */
public class Demo {

    public static void main(String[] args) {

        String str = "2020-05-16 19:20:34|user.login|name=Charles&location=Beijing&device=iPhone";

        method(str);

    }

    public static String method(String str) {

        int i = str.lastIndexOf('|');
        String substring = str.substring(i + 1, str.length());
        String[] temp = substring.split("&");

        StringBuilder stringBuilder = new StringBuilder("{");

        for (int j = 0; j < temp.length; j++) {
            String[] split = temp[j].split("=");
            stringBuilder.append(split[0]).append(":").append("\"").append(split[1]).append("\"");
            if (j != temp.length - 1) {
                stringBuilder.append(",");
            }
        }
        stringBuilder.append("}");
        return stringBuilder.toString();
    }

}
